package com.backend.demo.Interceptor;

import com.backend.demo.entities.Users;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

/**
 * 登录拦截器
 * @author Administrator
 *
 */
public class LoginInterceptor extends MethodFilterInterceptor{

	private static final long serialVersionUID = 1L;

	@Override
	protected String doIntercept(ActionInvocation invocation) throws Exception {
		Users user = (Users)invocation.getInvocationContext().getSession().get("user");
		if(user == null){
			return Action.ERROR;
		}
		return invocation.invoke();
	}
}
